<template>
  <div class="cs-warning-label">
    <div class="nbBoxL" :class="levelClass1(level)" :style="width_L">超</div>
    <div class="nbBoxR" :class="levelClass2(level)">
      {{ percent }}
    </div>
  </div>
</template>

<script>
export default {
  props: {
    percent: {
      type: String,
      require: true
    },
    level: {
      type: String,
      require: true
    },
    width_L: {
      type: String,
      default: 'width: 25px'
    }
  },
  methods: {
    levelClass1(carLevel) {
      if (carLevel === 'success') {
        return 'success1'
      } else if (carLevel === 'warning') {
        return 'warning1'
      } else if (carLevel === 'serious') {
        return 'serious1'
      } else {
        return 'danger1'
      }
    },
    levelClass2(carLevel) {
      if (carLevel === 'success') {
        return 'success2'
      } else if (carLevel === 'warning') {
        return 'warning2'
      } else if (carLevel === 'serious') {
        return 'serious2'
      } else {
        return 'danger2'
      }
    }
  }
}
</script>

<style scoped>
.cs-warning-label {
  height: 34px;
  line-height: 34px;
  margin-top: 10px;
  margin-bottom: 10px;
  font-size: 18px;
}

.nbBoxL {
  height: 100%;
  float: left;
  color: #fff;
  text-align: center;
}

.nbBoxR {
  height: 100%;
  float: left;
  color: #fff;
  text-align: center;
  padding: 0 7px;
}

/* 等级所对应的样式 */
.success1 {
  background-color: #00c952;
}

.success2 {
  background-color: #82e7ab;
}

.warning1 {
  background-color: #f7b503;
}

.warning2 {
  background-color: #ffe59e;
}

.serious1 {
  background-color: #f56606;
}

.serious2 {
  background-color: #ffb685;
}

.danger1 {
  background-color: #de2020;
}

.danger2 {
  background-color: #ffacac;
}
</style>
